package com.wuliu.business.person;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.wuliu.model.person.Person;
import com.wuliu.util.DbPool;

public class PersonObj {
	public static Person getPersonById(String id){
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		Person person = new Person();
		if(id==null || id.equals(""))
			return person;
		String strsql = "SELECT * FROM WL_PERSON WHERE PER_ID=?";
		try{
			conn = DbPool.getConnection();
			pstmt = conn.prepareStatement(strsql);
			pstmt.setString(1,id);
			rs = pstmt.executeQuery();
			if(rs.next()){
				person.setPerId(rs.getString("PER_ID"));
				person.setPerName(rs.getString("PER_NAME"));
				person.setPerCode(rs.getString("PER_CODE"));
				person.setPerTel(rs.getString("PER_TEL"));
				person.setPerMail(rs.getString("PER_MAIL"));
				person.setPerGender(rs.getString("PER_GENDER"));
				person.setPerAddr(rs.getString("PER_ADDR"));
				person.setAddBy(rs.getString("ADD_BY"));
				person.setAddDate(rs.getString("ADD_DATE"));
				person.setAddTime(rs.getString("ADD_TIME"));
				person.setUpdBy(rs.getString("UPD_BY"));
				person.setUpdDate(rs.getString("UPD_DATE"));
				person.setUpdTime(rs.getString("UPD_TIME"));
				person.setPerStatus(rs.getString("PER_STATUS"));
			}
		}catch(SQLException sqlE){
			sqlE.printStackTrace();
		}finally{
			DbPool.close(conn, pstmt, rs);
		}
		return person;
	}
}
